package com.huyanqi.core.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;

public class FileUploadUtils {

	public static void copyFile(InputStream in,String fileName,String filePath) throws Exception{
		FileOutputStream fs;
		File f = new File(filePath);
		if(!f.exists()){
			f.mkdirs();
		}
		fs = new FileOutputStream(filePath+"/"+ fileName);
		byte[] buffer = new byte[1024 * 1024];
		int bytesum = 0;  
		int byteread = 0;  
		while ((byteread = in.read(buffer)) != -1) {  
			bytesum += byteread;  
			fs.write(buffer, 0, byteread);  
			fs.flush();  
		}
		fs.close();  
		in.close(); 
    }
	
}
